home *** CD-ROM | disk | FTP | other *** search
- global gMethods, gStuMethod
-
- on loadMethod thePath
- global gSMSPath, gSlash, gStuInfo
- set gMethods to []
- set theFile to thePath & ".sav"
- set strList to readPropTextFile(theFile)
- if strList = EMPTY then
- return 0
- else
- set gStuMethod to strList
- registerVolume(getaProp(gStuMethod, #volume))
- set theFile to gSMSPath & "methods" & gSlash & getaProp(gStuInfo, #method) & ".met"
- set strList to readPropTextFile(theFile)
- if strList = EMPTY then
- return 0
- else
- set gMethods to strList
- return 1
- end if
- end if
- end
-
- on saveMethod
- global gSMSStuPath
- set theFile to gSMSStuPath & ".sav"
- if getaProp(gStuMethod, #action) = #inTest then
- setaProp(gStuMethod, #currPageScore, getWholeScore())
- saveRecord()
- else
- setaProp(gStuMethod, #currPageScore, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- end if
- writePropTextFile(theFile, gStuMethod)
- end
-
- on saveRecord
- global gMethods, gNewChap, gSMSStuPath, gType, gStartTime
- set newline to RETURN
- set sc to getScore()
- set theRecord to the date & "," & the time & "," & formatTime(the ticks - gStartTime) & "," & getaProp(gMethods, #name) & "," & gNewChap & "," & getaProp(sc, #right) & "," & getaProp(sc, #wrong) & newline
- set theFile to gSMSStuPath & ".rec"
- set theOldRec to readTextFile(theFile)
- if word 1 of theOldRec = "#Error" then
- set oldStuff to EMPTY
- else
- set x to decrypt(theOldRec)
- set oldStuff to x
- end if
- writePropTextFile(theFile, oldStuff & theRecord)
- end
-
- on getSMSNextMode lastScore
- global gStuInfo, gTest
- set m to getaProp(gStuMethod, #methodList)
- if m = [] then
- if lastScore = #firstTime then
- if getaProp(gStuMethod, #action) = #passed then
- set curr to getaProp(gStuMethod, #unitchap)
- setaProp(gStuMethod, #unitchap, curr + 1)
- if curr < getaProp(gStuInfo, #lastunitchap) then
- set m to createMethodList(getaProp(gMethods, #list), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- setaProp(gStuMethod, #action, #doTest)
- else
- setaProp(gStuMethod, #action, #finished)
- end if
- else
- if getaProp(gStuMethod, #action) = #failed then
- set m to createMethodList(getaProp(gMethods, #list), getaProp(gStuMethod, #currPageScore))
- setaProp(gStuMethod, #action, #doTest)
- else
- if getaProp(gStuMethod, #action) <> #finished then
- set m to createMethodList(getaProp(gMethods, #list), [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- end if
- end if
- end if
- setaProp(gStuMethod, #methodList, m)
- setaProp(gStuMethod, #currPageScore, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
- else
- end if
- else
- set tmp to getAt(m, 1)
- if (getaProp(tmp, #redoWrong) = 1) and (lastScore = #wasWrong) then
- set num to count(m)
- set insPoint to 5
- set done to 0
- repeat while done = 0
- if num < insPoint then
- add(m, tmp)
- set done to 1
- next repeat
- end if
- set oneBefore to getAt(m, insPoint - 1)
- set mode to getaProp(oneBefore, #mode)
- if (mode <> "A") and (mode <> "B") and (mode <> "C") then
- addAt(m, insPoint, tmp)
- set done to 1
- next repeat
- end if
- set insPoint to insPoint + 1
- end repeat
- end if
- if lastScore <> #firstTime then
- deleteAt(m, 1)
- end if
- if (lastScore = #firstTime) and (getaProp(gStuMethod, #action) = #inTest) then
- set gTest to 1
- set currPage to getaProp(getAt(getaProp(gStuMethod, #methodList), 1), #page)
- set scores to getaProp(gStuMethod, #currPageScore)
- clearScore()
- repeat with i = 1 to currPage - 1
- set pagescore to getAt(scores, i)
- updateScore(i, pagescore)
- if pagescore <> 10 then
- updateScore(i, pagescore - 10)
- end if
- end repeat
- end if
- end if
- set act to #normal
- set c to count(m)
- if c = 0 then
- if getaProp(gStuMethod, #action) = #doTest then
- setaProp(gStuMethod, #action, #inTest)
- set m to createTestList(getaProp(gMethods, #testMode), getaProp(gMethods, #testBlindfold))
- setaProp(gStuMethod, #methodList, m)
- set next to getaProp(getAt(m, 2), #page)
- set act to #enterTest
- setaProp(gStuMethod, #action, #inTest)
- else
- if getaProp(gStuMethod, #action) = #inTest then
- set sc to getScore()
- set total to getaProp(sc, #right) + getaProp(sc, #wrong)
- set percent to getaProp(sc, #right) * 100 / total
- if percent < getaProp(gStuInfo, #proficiency) then
- setaProp(gStuMethod, #action, #failed)
- else
- setaProp(gStuMethod, #action, #passed)
- end if
- return [#action: #finishedTest]
- else
- if getaProp(gStuMethod, #action) = #finished then
- return [#action: #finishedAll]
- else
- set curr to getaProp(gStuMethod, #unitchap)
- if curr < getaProp(gStuInfo, #lastunitchap) then
- setaProp(gStuMethod, #unitchap, curr + 1)
- return getSMSNextMode(#firstTime)
- end if
- return [#action: #finishedAll]
- end if
- end if
- end if
- else
- if c = 1 then
- set next to 1
- else
- set next to getaProp(getAt(m, 2), #page)
- end if
- end if
- return [#action: act, #unitchap: getaProp(gStuMethod, #unitchap), #page: getaProp(getAt(m, 1), #page), #mode: getaProp(getAt(m, 1), #mode), #blindfold: getaProp(getAt(m, 1), #blindfold), #nextunitchap: getaProp(gStuMethod, #unitchap), #nextPage: next, #language: getaProp(gStuInfo, #language), #allowBrowse: getaProp(getAt(m, 1), #allowBrowse)]
- end
-
- on createMethodList method, pageScores
- set mlist to []
- set currpos to 1
- set nummodes to count(method)
- set index to []
- repeat with m = 1 to nummodes
- add(index, [#i: getaProp(getAt(method, m), #startPage), #e: getaProp(getAt(method, m), #endPage)])
- end repeat
- repeat while moreToDo(index)
- repeat with m = 1 to nummodes
- set i to getaProp(getAt(index, m), #i)
- if i <> -1 then
- set o to getaProp(getAt(method, m), #offset)
- if currpos >= o then
- set hasPassed to getAt(pageScores, i) = 10
- addmode(mlist, getAt(method, m), i, hasPassed)
- incIdx(getAt(index, m))
- end if
- end if
- end repeat
- set currpos to currpos + 1
- end repeat
- return mlist
- end
-
- on incIdx index
- set i to getaProp(index, #i)
- set i to i + 1
- if i <= getaProp(index, #e) then
- setaProp(index, #i, i)
- else
- setaProp(index, #i, -1)
- end if
- end
-
- on moreToDo index
- set num to count(index)
- repeat with i = 1 to num
- if getaProp(getAt(index, i), #i) <> -1 then
- return 1
- end if
- end repeat
- return 0
- end
-
- on addmode mlist, modeset, i, hasPassed
- if hasPassed = 0 then
- add(mlist, [#page: i, #mode: getaProp(modeset, #mode), #blindfold: getaProp(modeset, #blindfold), #redoWrong: getaProp(modeset, #redoWrong), #allowBrowse: getaProp(modeset, #allowBrowse)])
- end if
- end
-
- on setTutorial which
- global gStuInfo, gNewChap, gOrder
- if which = 1 then
- set gMethods to value(the text of cast "tutorial 1")
- else
- set gMethods to value(the text of cast "tutorial 2")
- end if
- set gOrder to value(the text of cast "order")
- set idx to mapUC2Index(word 2 of gNewChap)
- setaProp(gStuInfo, #language, ChapStr2Language(gNewChap))
- setaProp(gStuInfo, #proficiency, 0)
- setaProp(gStuInfo, #lastunitchap, idx)
- setaProp(gStuMethod, #unitchap, idx)
- setaProp(gStuMethod, #methodList, [])
- setaProp(gStuMethod, #currPageScore, [])
- setaProp(gStuMethod, #action, #skipTest)
- end
-
- on createTestList mode, blindfold
- set mlist to []
- repeat with i = 1 to 10
- add(mlist, [#page: i, #mode: mode, #blindfold: blindfold, #redoWrong: 0, #allowBrowse: 0])
- end repeat
- return mlist
- end
-